/**
 * @file ringBuffer.h
 * @author xzq
 * @brief
 * @version 0.1
 * @date 2024-10-26
 *
 * @copyright Copyright (c) 2024
 *
 */
#ifndef _RINGBUFFER_H
#define _RINGBUFFER_H

#include "stdint.h"

enum rbStatus
{
	rbSuccess,
	rbFail,
};

typedef enum rbStatus rbStatus_t;

struct xRingBuffer
{
	int8_t *rbBuffer;
	int8_t *rbHead;
	int8_t *rbTail;
	uint32_t rbSize;
};

typedef struct xRingBuffer xRingBuffer_t;

#ifdef __cplusplus
extern "C"
{
#endif

extern rbStatus_t xRingBufferCreate(xRingBuffer_t *rb, uint32_t size);
extern void xRingBufferFlush(xRingBuffer_t *rb);
extern rbStatus_t xRingBufferDestory(xRingBuffer_t *rb);
extern rbStatus_t xRingBufferCapacity(xRingBuffer_t *rb, uint32_t *capacity);
extern rbStatus_t xRingBufferIsRead(xRingBuffer_t *rb);
extern rbStatus_t xRingBufferGenericRead(xRingBuffer_t *rb, void *date, uint32_t size, uint32_t *read);
extern rbStatus_t xRingBufferGenericWrite(xRingBuffer_t *rb, void *date, uint32_t size, uint32_t *write);
extern rbStatus_t xRingBufferRead(xRingBuffer_t *rb, void *date, uint32_t size);
extern rbStatus_t xRingBufferWrite(xRingBuffer_t *rb, void *date, uint32_t size);

#ifdef __cplusplus
}
#endif

#endif
